<?php
/**
 * @fileName:StaticFactory.php
 * @project:basic_knowledge
 * @author : 吐火青蛙
 * @user : 吐火青蛙
 * @date : 2020/4/10
 *
 */

namespace miaosang\basicknowledge\design\staticfactory;
use miaosang\basicknowledge\design\staticfactory\FormatNumber;
use miaosang\basicknowledge\design\staticfactory\FormatString;

final class StaticFactory
{
    public static function factory(string $type): FormatterInterface
    {
        if ($type == 'number') return new FormatNumber();
        if ($type == 'string') return new FormatString();
        throw new \InvalidArgumentException('Unknown format given');
    }
}
